<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="file" id="file" />
    <script>
      //   let str = "<div>杜瑶智是猪</div>";
      //   let blob = new Blob([str], {
      //     type: "text/html",
      //   });
      //   let a = document.createElement("a");
      //   a.setAttribute("download", "index.html");
      //   a.href = URL.createObjectURL(blob);
      //   a.click();
      file.addEventListener("change", (e) => {
        let file = e.target.files[0];
        // let fileReader = new FileReader();
        // fileReader.readAsDataURL(file);
        // fileReader.onload = (res) => {
        //   let img = document.createElement("img");
        //   img.src = res.target.result;
        //   document.body.appendChild(img);
        // };
        let img = document.createElement("img");
        let url = URL.createObjectURL(file);
        img.src = url;
        document.body.appendChild(img);
        URL.revokeObjectURL(url);
      });
    </script>
  </body>
</html>
